<template>
  <div>
    <div class="supplier-info">
      <mt-cell :title="supplier.shop_name"><img slot="icon" :src="supplier.img" width="24" height="24"></mt-cell>
      <mt-cell title="负责人手机：" :value="supplier.mobile"></mt-cell>
      <mt-cell title="退出登录" v-on:click.native="logout"></mt-cell>
    </div>
    <v-nav :isActive="isActive"></v-nav>
  </div>
</template>

<script type="text/ecmascript-6">
  import nav from '@/components/nav/nav'
  import { Cell, Indicator } from 'mint-ui'
  export default {
    data: () => {
      return {
        isActive: '1',
        supplier: []
      }
    },
    components: {
      'v-nav': nav,
      Cell,
      Indicator
    },
    created: function () {
      /* Indicator.open({
        text: '加载中...',
        spinnerType: 'fading-circle'
      }) */
      var token = this.$store.getters.getToken
      var url = process.env.BASE_API + '/supplier/user/getSupplierInfo?token=' + token
      this.$http.get(url, {emulateJSON: true}).then(response => {
        var res = response.body
        if (res.code === 1000) {
          this.supplier = res.data
          this.supplier.img = 'http://img.dawangfu.com' + this.supplier.img
        } else {
          this.$router.push({path: '/'})
        }
      })
    },
    methods: {
      logout: function () {
        sessionStorage.clear()
        this.$store.dispatch('setToken', '')
        this.$store.dispatch('setLogin', 0)
        this.$router.push({path: '/'})
      }
    }
  }
</script>

<style lang="stylus" rel="stylesheet/stylus">

</style>
